package com.dennisstepp.activities;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.dennisstepp.depressionglass.activities.DepressionGlassActivity;
import com.dennisstepp.tabwidget.BosculTabWidget;
import com.dennisstepp.tabwidget.SuperheroTabWidget;

public class MainMenuActivity extends ListActivity {

	static final ListItemActivities[] collections = {
			new ListItemActivities("Depression Glass",
					DepressionGlassActivity.class),
			new ListItemActivities("Boscul", BosculTabWidget.class),
			new ListItemActivities("Superhero", SuperheroTabWidget.class) };
	TextView selection;

	/**
	 * Called when the activity is first created. Gives the ListAdapter a layout
	 * defined in XML, and array of Items which populate this layout
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new ArrayAdapter<ListItemActivities>(this,
				android.R.layout.simple_list_item_1, collections));
	}

	/**
	 * Provides a means to reach the Activity classes that match the selections
	 * position.
	 */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		final Intent intent = new Intent(this,
				collections[position].getActivity());
		startActivityForResult(intent, position);
	}
}